# encoding: UTF-8
"""

@author = 李林名
@email = lishuai1199@qq.com
@create_time = 2022/11/23 23:44

"""

from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep


#1.获取t1ID中的p,span标签: 李白 静夜思 杜甫 春夜喜雨
wd = webdriver.Chrome()
wd.get('https://cdn2.byhy.net/files/selenium/sample1a.html')
## 根据属性选择元素
elements = wd.find_elements(By.CSS_SELECTOR, '#t1>span,#t1>p')
## 打印出元素对应的html
for element in elements:
    print(element.get_attribute('innerHTML'))
sleep(1)